package cn.fj.data.service.impl;

import cn.fj.basic.util.PageList;
import cn.fj.data.domain.Type;
import cn.fj.data.mapper.TypeMapper;
import cn.fj.data.query.TypeQuery;
import cn.fj.data.service.ITypeService;
import cn.fj.org.domain.Department;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TypeServiceimpl implements ITypeService{

  @Autowired
  private TypeMapper typemapper;
    @Override
    public void add(Type Type) {
        typemapper.add(Type);//添加数据的时候，获取主键自增
        //调用update
        modify(Type);

    }

    @Override
    public void delete(long id) {
        typemapper.delete(id);


    }

    @Override
    /*修改*/
    public void modify(Type Type) {
        typemapper.modify(Type);


    }


    @Override
    public List<Type> queryAll() {
        List<Type> dictionaries = typemapper.queryAll();
        return dictionaries;
    }

    @Override
    public Type queryOne(Long id ) {
        Type Type = typemapper.queryOne();
        return Type;
    }


    @Override
    public PageList<Type> queryData(TypeQuery Typequery) {
        Integer count = typemapper.count(Typequery);
        System.out.println(count);
        //查询每页数据
        List<Type> list = typemapper.queryData(Typequery);
        PageList<Type> PageList = new PageList<Type>(count, list);
        return  PageList;
    }

    @Override
    public void allDelete(List<Long> ids) {
        typemapper.allDelete(ids);

    }

    @Override
    public List<Department> depTree() {
        return null;
    }
}
